<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-page-header content="商机编辑" @back="$router.back()" />
        </el-card>
        <el-card class="mt-4 !border-none" shadow="never" @tab-click="handleClick">
            <el-tabs v-model="activeName">
                <el-tab-pane label="基本信息" name="first">
                    <edit-popup v-if="showEdit" ref="editRef" />
                </el-tab-pane>
                <el-tab-pane label="跟进动态" name="followUp">
                    <followup-popup v-if="followupEdit" ref="addLinkEditRef"
                /></el-tab-pane>
                <el-tab-pane label="联系人" name="second">
                    <add-link-edit-popup v-if="addLinkshowEdit" ref="addLinkEditRef"
                /></el-tab-pane>
                <el-tab-pane label="附件" name="third"
                    ><file-popup v-if="followupEdit" ref="addLinkEditRef"
                /></el-tab-pane>
                <el-tab-pane label="提醒" name="fourth">
                    <remind-popup v-if="remindshowEdit" ref="addLinkEditRef"
                /></el-tab-pane>
            </el-tabs>
        </el-card>
    </div>
</template>

<script lang="ts" setup>
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
import AddLinkEditPopup from '../component/linkMan/addLinkMan.vue'
const addLinkEditRef = shallowRef<InstanceType<typeof AddLinkEditPopup>>()
import FollowupPopup from '../component/followup/followup.vue'
const followupEditRef = shallowRef<InstanceType<typeof FollowupPopup>>()
import RemindPopup from '../component/remind/index.vue'
const remindEditRef = shallowRef<InstanceType<typeof RemindPopup>>()
import FilePopup from '../clientFile/index.vue'
const fileEditRef = shallowRef<InstanceType<typeof FilePopup>>()
const showEdit = ref(true)
const addLinkshowEdit = ref(true)
const remindshowEdit = ref(true)
const followupEdit = ref(true)
const fileEdit = ref(true)
import { nextTick } from 'vue'

const handleClick = async (tab, event) => {
    if (tab == 'first') {
        showEdit.value = true
        await nextTick()
        editRef.value?.open()
    } else if (tab == 'second') {
        addLinkshowEdit.value = true
        await nextTick()
        addLinkEditRef.value?.open()
    } else if (tab == 'followUp') {
        followupEdit.value = true
        await nextTick()
        followupEditRef.value?.open()
    } else if (tab == 'fourth') {
        remindshowEdit.value = true
        await nextTick()
        remindEditRef.value?.open()
    } else if (tab == 'third') {
        fileEdit.value = true
        await nextTick()
        fileEditRef.value?.open()
    }
}
const activeName = 'first'
</script>
<style></style>
